import { Controller, Post, Body } from '@nestjs/common';
import { UserService } from './user.service';
import { AuthingService } from '../authing/authing.service';

@Controller('user')
export class UserController {
  constructor(
    private readonly userService: UserService,
    private readonly authingService: AuthingService
  ) {}

  @Post('getUser')
  async getUser(@Body() data: { access_token: string }) {
    const user = await this.authingService.getUser(data.access_token);
    const userData = {
      name: user.data.username ,  
      mobile: user.data.phone ,
      photo: user.data.photo ,
      token: data.access_token
    };
    return await this.userService.setUsers(userData);
  }
}
